package resource.pojo;

import java.io.Serializable;
import java.sql.ResultSet;
import models.util.MySqlDataAccessHelper;

public class TypeApprove implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private Integer idTypeApprove;
	private String typeName;
	private Integer iDConfigStaticLang;
	private String description;
	private ConfigStaticLang configStaticLang;
	MySqlDataAccessHelper mysqlHelper = new MySqlDataAccessHelper();

	public MySqlDataAccessHelper getMysqlHelper() {
		return mysqlHelper;
	}

	public void setMysqlHelper(MySqlDataAccessHelper mysqlHelper) {
		this.mysqlHelper = mysqlHelper;
	}

	public TypeApprove() {

	}

	public TypeApprove(Integer iDConfigStaticLang) {
		this.iDConfigStaticLang = iDConfigStaticLang;
	}

	public TypeApprove(Integer idTypeApprove, String typeName,
			Integer iDConfigStaticLang, String description) {
		this.idTypeApprove = idTypeApprove;
		this.typeName = typeName;
		this.iDConfigStaticLang = iDConfigStaticLang;
		this.description = description;
	}

	public Integer getIdTypeApprove() {
		return idTypeApprove;
	}

	public void setIdTypeApprove(Integer idTypeApprove) {
		this.idTypeApprove = idTypeApprove;
	}

	public String getTypeName() {
		return typeName;
	}

	public void setTypeName(String typeName) {
		this.typeName = typeName;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public Integer getiDConfigStaticLang() {
		return iDConfigStaticLang;
	}

	public void setiDConfigStaticLang(Integer iDConfigStaticLang) {
		this.iDConfigStaticLang = iDConfigStaticLang;
	}

	public ConfigStaticLang getConfigStaticLang() {
		if (this.iDConfigStaticLang == 0)
			return configStaticLang = null;
		mysqlHelper.open();
		try {
			String sql = "select * from staticlang where IDConfigStaticLang="
					+ this.iDConfigStaticLang;
			ResultSet rs = mysqlHelper.executeQuery(sql);
			if (rs.next())
				configStaticLang = new ConfigStaticLang(
						rs.getInt("IDConfigStaticLang"), rs.getString("VN"),
						rs.getString("KR"), rs.getString("EN"));
			else
				configStaticLang = null;
		} catch (Exception e) {
		} finally {
			mysqlHelper.close();
		}
		return configStaticLang;
	}

	public void setConfigStaticLang(ConfigStaticLang configStaticLang) {
		this.configStaticLang = configStaticLang;
	}

	@Override
	public String toString() {
		return "Name :" + this.typeName;
	}
}
